<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>lesson 29</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id="root"></div>
</body>

</html>

<script>
    // 自定义指令  directive
    const app = Vue.createApp({
        // 定义局部指令：实现自动获取焦点
        // directives: directives,
        template: `
        <div>
            <input v-focus/>
        </div>
        `
    });

    // 定义全局指令：实现自动获取焦点
    app.directive('focus', {
        mounted(el) {
            el.focus()
        },
    });

    //  定义局部的指令：实现自动获取焦点
    // const directives = {
    //     focus: {
    //         mounted(el) {
    //             el.focus();
    //         },
    //     }
    // }


    const vm = app.mount("#root");
</script>